<!--Copyright (C) Kherty.  All rights reserved.-->
<UserControl
    xmlns:ssui="clr-namespace:OpenLS.Spreadsheet.UI"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    xmlns:Internals="clr-namespace:OpenLS.Spreadsheet.UI.Internals"
    xmlns:Resources="clr-namespace:OpenLS.Spreadsheet.UI.Internals.Resources"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    x:Class="OpenLS.Spreadsheet.UI.LoginControl"
    FocusManager.FocusedElement="{Binding ElementName=NameTextBox}"
    Width="320" Height="200"
    >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ssui:DialogResources/>

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <!--Title="New Name"-->
    <Border BorderBrush="Black" BorderThickness="1" Background="Beige" CornerRadius="18" Padding="10">
        <Grid>
            <Grid.Resources>
                <Style TargetType="{x:Type TextBox}">
                    <Setter Property="Margin" Value="4"/>
                    <Setter Property="VerticalAlignment" Value="Center"/>
                </Style>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Height" Value="24"/>
                </Style>
                <Style TargetType="{x:Type dxe:TextEdit}">
                    <Style.Triggers>
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
                <Style TargetType="{x:Type dxe:PasswordBoxEdit}">
                    <Style.Triggers>
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition  Height="Auto"/>
                <RowDefinition  Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition  Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Label  Margin="3" Content="{x:Static Resources:UIStringTable.User}"/>
            <dxe:TextEdit Text="{Binding UserName,  ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Name="UserTextBox"  TabIndex="0" Grid.Row="0"  Grid.Column="1"  MaskAutoComplete="None"  Margin="2,2,10,2" Height="25"/>
            <Label  Grid.Row="2" Content="{x:Static Resources:UIStringTable.Password}" />
            <dxe:PasswordBoxEdit Text="{Binding Password, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Name="PasswordTextBox" Grid.Column="1" Grid.Row="2" TabIndex="1" Margin="2,2,10,2" Height="25" />
            <CheckBox x:Name="IsPasswordForgottenCheckbox" HorizontalAlignment="Center" IsChecked="{Binding IsPasswordForgotten}"  Grid.Row="3" Grid.Column ="0"/>
            <TextBlock TextWrapping="WrapWithOverflow" Grid.Row="3" Grid.Column ="1" Height="40" Text="{x:Static Resources:UIStringTable.ForgotPassword}">
            </TextBlock>
            <TextBlock Foreground="Red" Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Top" Height="20"  Text="{Binding Error}"/>
            <StackPanel Grid.Row="5" Grid.Column ="1"  HorizontalAlignment="Right" Orientation="Horizontal">
                <Button  Content="OK" Click="OnOkClicked">
                    <Button.Style>
                        <Style TargetType="{x:Type Button}">
                            <Setter Property="Width" Value="60" />
                            <Setter Property="Height" Value="30" />
                            <Setter Property="IsEnabled" Value="false" />
                            <Style.Triggers>
                                <!-- Require the controls to be valid in order to press OK -->
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding ElementName=UserTextBox, Path=(Validation.HasError)}" Value="false" />
                                        <Condition Binding="{Binding ElementName=PasswordTextBox, Path=(Validation.HasError)}" Value="false" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="IsEnabled" Value="true" />
                                </MultiDataTrigger>
                                <MultiDataTrigger>
                                    <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding ElementName=UserTextBox, Path=(Validation.HasError)}" Value="false" />
                                        <Condition Binding="{Binding ElementName=IsPasswordForgottenCheckbox, Path=(IsChecked)}" Value="true" />
                                    </MultiDataTrigger.Conditions>
                                    <Setter Property="IsEnabled" Value="true" />
                                </MultiDataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>
                <Button  Content="Cancel"  Click="OnCancelClicked"  Width="60" Height="30"/>
            </StackPanel>
           

        </Grid>
    </Border>
</UserControl>
